package cn.jolywood.cloud.module.crm.dal.mysql.obtainguest;


import cn.jolywood.cloud.framework.common.pojo.PageResult;
import cn.jolywood.cloud.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.jolywood.cloud.framework.mybatis.core.mapper.BaseMapperX;
import cn.jolywood.cloud.module.crm.dal.dataobject.obtainguest.ObtainGuestDO;
import org.apache.ibatis.annotations.Mapper;
import cn.jolywood.cloud.module.crm.controller.admin.obtainguest.vo.*;

/**
 * 订单获客主 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ObtainGuestMapper extends BaseMapperX<ObtainGuestDO> {

    default PageResult<ObtainGuestDO> selectPage(ObtainGuestPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ObtainGuestDO>()
                .likeIfPresent(ObtainGuestDO::getObtainGuestNo, reqVO.getObtainGuestNo())
                .eqIfPresent(ObtainGuestDO::getClientType, reqVO.getClientType())
                .likeIfPresent(ObtainGuestDO::getClientName, reqVO.getClientName())
                .likeIfPresent(ObtainGuestDO::getTaxNumber, reqVO.getTaxNumber())
                .likeIfPresent(ObtainGuestDO::getClientPhone, reqVO.getClientPhone())
                .eqIfPresent(ObtainGuestDO::getBusinessManagerId, reqVO.getBusinessManagerId())
                .likeIfPresent(ObtainGuestDO::getBusinessManagerPhone, reqVO.getBusinessManagerPhone())
                .eqIfPresent(ObtainGuestDO::getPayType, reqVO.getPayType())
                .eqIfPresent(ObtainGuestDO::getSellType, reqVO.getSellType())
                .eqIfPresent(ObtainGuestDO::getContractType, reqVO.getContractType())
                .eqIfPresent(ObtainGuestDO::getProductType, reqVO.getProductType())
                .eqIfPresent(ObtainGuestDO::getClientAreaId, reqVO.getClientAreaId())
                .likeIfPresent(ObtainGuestDO::getClientDetailAddress, reqVO.getClientDetailAddress())
                .likeIfPresent(ObtainGuestDO::getRemark, reqVO.getRemark())
                .orderByDesc(ObtainGuestDO::getId));
    }

    default ObtainGuestDO selectByNo(String no) {
        return selectOne(ObtainGuestDO::getObtainGuestNo, no);
    }

}